﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;

namespace FFWinMobile
{
    public partial class frmAbout : Form
    {
        public frmAbout()
        {
            InitializeComponent();
        }

        private void frmAbout_Load(object sender, EventArgs e)
        {
            lblVersion.Text = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
        }

        private void menuItem1_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void miCheckVersion_Click(object sender, EventArgs e)
        {

            HttpWebRequest r = (HttpWebRequest)WebRequest.Create("http://www.bahadirarslan.com/ffwinmobile.txt");
            r.Method = "GET";
            HttpWebResponse res = (HttpWebResponse)r.GetResponse();
            using (StreamReader sr = new StreamReader(res.GetResponseStream()))
            {
                Version latestVer = new Version(sr.ReadToEnd());
                Version actualVer = System.Reflection.Assembly.GetExecutingAssembly().GetName().Version;
                int compare = latestVer.CompareTo(actualVer);
                if (compare == 0)
                {
                    MessageBox.Show(Properties.Resources.VERSION_0);
                }
                else if (compare > 0)
                {
                    MessageBox.Show(Properties.Resources.VERSION_1);
                }

            }
            res.Close();
            
        }
    }
}